home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Hardware / Mac OS USB DDK / Mac OS USB DDK 1.4.1 / USB Software Locator Kit / SampleDriverInstallerExample / SampleInstall.r < prev    next >
Encoding:
Text File  |  2000-04-25  |  17.5 KB  |  622 lines  |  [TEXT/R*ch]

  1. /*
  2.     File:        SampleInstall.r
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8. */
  9.  
  10.  
  11. #include "Types.r"
  12. #include "InstallerTypes.r"
  13. #include "Gestalt.r"
  14. #include "AtomDefs.h"
  15.  
  16. //======================================================================
  17. // Gestalt constant as yet not defined in Gestalt.h UI&L 3.2
  18. //======================================================================
  19.  
  20. #define gestaltPowerMacNewWorld    406
  21. #define gestaltPowerExpress        409        //    for never released cpu still common at apple
  22.  
  23.  
  24. //======================================================================
  25. // Global constants
  26. //======================================================================
  27.  
  28. // Assertion contants
  29.  
  30. #define aPCIPowerMac            1
  31. #define aHasOKSystem            2
  32. #define aHasUSB14                3
  33.  
  34.  
  35.  
  36. // Rule contants
  37.  
  38. #define rHasOKSystem            701
  39. #define rIsPCIPowerPC            702
  40. #define rHasUSB14                703
  41. #define rSampleInstall            704
  42. #define rSampleInstall14        705
  43. #define rSampleInstallPre14        706
  44. #define cSampleInstall            707
  45. #define cSampleInstall14        708
  46. #define cSampleInstallPre14        709
  47.  
  48.  
  49. #define errSystemNotOK            750
  50. #define errMachineNotOK            751
  51.  
  52. // constants for packages, comments, comment text
  53.  
  54. #define pSample                    801
  55. #define pSampleLiveUpdate        802
  56.  
  57.  
  58. // file atom constants
  59.  
  60. #define faSampleDriver            1000
  61. #define faSampleShim            1001
  62.  
  63. // file target constants
  64.  
  65.  
  66. #define ftSampleDriver            2000
  67. #define ftSampleShim            2001
  68.  
  69. // source target constants
  70.  
  71. #define fsSystemFile            900
  72.  
  73. #define fsSampleDriver            1000
  74. #define fsSampleShim            1001
  75. #define fsSampleTome            1002
  76.  
  77. #define aaAddShimToDisk            9000
  78. #define rlUSBVersFn14            9001
  79.  
  80. include "InstaCompAtomExt.rsrc" 'inex' (242);
  81. include "InstaCompAtomExt.rsrc" 'exfn' (242);
  82.  
  83. //======================================================================
  84. // Version String constants
  85. //======================================================================
  86.  
  87. #define SampleVersionString            "1.0d1"
  88. #define SampleHexVersion            0x01001000
  89.  
  90.  
  91. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  92. //
  93. // • Installer Version Resource
  94. //
  95. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  96.  
  97. // This way the Installer script can only be opened by Installer Engine 4.5 and later.
  98. resource 'invs' (1) {
  99.     format0 {    
  100.         0x04, 0x08, 0x80, 0x00,
  101.         "4.08"
  102.     }
  103. };
  104.  
  105.  
  106. //======================================================================
  107. // Global Framework resources ('infr')
  108. //======================================================================
  109.  
  110. //----------------------------------------------------------------------
  111. // • Global Rules FrameworkRsrc
  112. //
  113. // This framework is always called prior to the easy or custom install
  114. // frameworks.  Use it for global assertions and tests that need to
  115. // be done regardless of the type of intstall being done
  116. //----------------------------------------------------------------------
  117.  
  118. resource 'infr' (kGlobalFrameworkRsrcID) {
  119.     format0 {{
  120.         // run our global rules.
  121.         pickFirst, {
  122.             rHasOKSystem,
  123.             errSystemNotOK
  124.         },
  125.         pickFirst, {
  126.             rIsPCIPowerPC,
  127.             errMachineNotOK
  128.         },
  129.         pickFirst, {
  130.             rHasUSB14
  131.         }
  132.     }}
  133. };
  134.  
  135. //----------------------------------------------------------------------
  136. // • Easy Install FrameworkRsrc
  137. //
  138. // Easy install framework references all top-level packages that will be
  139. // installed when the user selects the 'Easy Install' option of the
  140. // Installer.
  141. //----------------------------------------------------------------------
  142.  
  143. resource 'infr' (kEasyInstallFrameworkRsrcID) {
  144.     format0 {{
  145.         // execute first true rule, if none are true then return false
  146.         pickFirst, {
  147.             rSampleInstall14, rSampleInstallPre14
  148.         },
  149.     }}
  150. };
  151.  
  152. //----------------------------------------------------------------------
  153. // • Custom Install FrameworkRsrc
  154. //
  155. // Custom install framework references all top-level packages that will be
  156. // visible when the user selects the 'Custom Install' option of the
  157. // Installer.
  158. //----------------------------------------------------------------------
  159.  
  160. resource 'infr' (kCustomInstallFrameworkRsrcID) {
  161.     format0 {{
  162.         // execute first true rule, if none are true then return false
  163.         pickFirst, {             // check CPU version, if PCI PowerMac but not New World system, then
  164.             cSampleInstall14, cSampleInstallPre14
  165.         },
  166.     }}
  167. };
  168.  
  169.  
  170. //======================================================================
  171. // Installer Rules resources ('inrl')
  172. //======================================================================
  173.  
  174. //----------------------------------------------------------------------
  175. // • Global Config rules
  176. //
  177. // Top-level rule that sets assertions depending on configuration
  178. //----------------------------------------------------------------------
  179.  
  180. resource 'inrl' (rHasOKSystem) 
  181. {
  182.     format0
  183.     {{
  184.         checkFileVersion {fsSystemFile, 8, 5, release, 0},
  185.         addAssertion {{aHasOKSystem}}
  186.     }};
  187. };
  188.  
  189. resource 'inrl' (rIsPCIPowerPC) 
  190. {
  191.     format0
  192.     {{
  193.         // Set the 'aPowerMac' assertion if this is a Power Macintosh which can have
  194.         // a USB PCI or Cardbus card installed
  195.         CheckGestalt{ gestaltMachineType, 
  196.             {     gestaltPowerMac6400,
  197.                 gestaltPowerMac9500,
  198.                 gestaltPowerMac7500,
  199.                 gestaltPowerMac8500,
  200.                 gestaltPowerMac5400,
  201.                 gestaltPowerMac7200,
  202.                 gestaltPowerMac7300,
  203.                 gestaltPowerMacG3,
  204.                 gestaltPowerMac5500,
  205.                 gestaltPowerMac6500,
  206.                 gestaltPowerMac4400_160,
  207.                 gestaltPowerMac4400,
  208.                 gestaltPowerExpress,
  209.                 gestaltPowerMacNewWorld}},
  210.         AddAssertion {{ aPCIPowerMac }}
  211.     }};
  212. };
  213.  
  214. resource 'inrl' (errSystemNotOK)
  215. {
  216.     format0
  217.     {{
  218.         reportVolError 
  219.         {
  220.             "This version of Mac OS USB can only be "
  221.             "installed on PCI Power Macintoshes running MacOS "
  222.             "8.5 or later!"
  223.         },
  224.     }};
  225. };
  226.  
  227. resource 'inrl' (errMachineNotOK)
  228. {
  229.     format0
  230.     {{
  231.         reportSysError 
  232.         {
  233.             "Mac OS USB can only be installed on a "
  234.             "PCI Power Macintosh System"
  235.         },
  236.     }};
  237. };
  238.  
  239. resource 'inrl' (rHasUSB14, "Check if USV v1.4 is present") 
  240. {
  241.     format0
  242.     {{
  243.         checkRuleFunction{ rlUSBVersFn14 },
  244.         AddAssertion {{ aHasUSB14 }}
  245.     }};
  246. };
  247.  
  248.  
  249.  
  250. //----------------------------------------------------------------------
  251. // • Rules to install the various packages
  252. //
  253. //----------------------------------------------------------------------
  254.  
  255. resource 'inrl' (rSampleInstall14) {
  256.     format0 {{
  257.         // this returns false unless OS is right version
  258.         checkAllAssertions{{ aHasOKSystem }},
  259.         
  260.         // this returns false unless CPU is PCI Power Macintosh
  261.         checkAllAssertions{{ aPCIPowerMac }},
  262.         
  263.         // this returns false unless CPU is PCI Power Macintosh
  264.         checkAllAssertions{{ aHasUSB14 }},
  265.         
  266.         // if PCI Power Macintosh CPU, add the Sample module package.
  267.         AddPackages{{ pSampleLiveUpdate }},
  268.         addUserDescription {"Click Install button to install\n" },
  269.         AddUserDescription{ "• Sample Prototype Driver " SampleVersionString ".\n" },
  270.         AddUserDescription{ "USB Version 1.4 or greater present" ".\n" },
  271.     }}
  272. };
  273.  
  274. resource 'inrl' (rSampleInstallPre14) {
  275.     format0 {{
  276.         // this returns false unless OS is right version
  277.         checkAllAssertions{{ aHasOKSystem }},
  278.         
  279.         // this returns false unless CPU is PCI Power Macintosh
  280.         checkAllAssertions{{ aPCIPowerMac }},
  281.         
  282.         // if PCI Power Macintosh CPU, add the Sample module package.
  283.         AddPackages{{ pSample }},
  284.         addUserDescription {"Click Install button to install\n" },
  285.         AddUserDescription{ "• Sample Prototype Driver " SampleVersionString ".\n" },
  286.         AddUserDescription{ "USB Version 1.3 or earlier present" ".\n" },
  287.     }}
  288. };
  289.  
  290.  
  291. //----------------------------------------------------------------------
  292. // • Custom Install rules
  293. //
  294. // rule that adds USB packages for the custom install.
  295. //----------------------------------------------------------------------
  296.  
  297. resource 'inrl' (cSampleInstall14) {
  298.     format0 {{
  299.         // this returns false unless OS is right version
  300.         checkAllAssertions{{ aHasOKSystem }},
  301.         
  302.         // this returns false unless CPU is PCI Power Macintosh
  303.         checkAllAssertions{{ aPCIPowerMac }},
  304.         
  305.         // this returns false unless CPU is PCI Power Macintosh
  306.         checkAllAssertions{{ aHasUSB14 }},
  307.         
  308.         // if PCI Power Macintosh CPU, add the Sample module package.
  309.         addCustomItems{{ pSampleLiveUpdate }},
  310.     }}
  311. };
  312.  
  313. resource 'inrl' (cSampleInstallPre14) {
  314.     format0 {{
  315.         // this returns false unless OS is right version
  316.         checkAllAssertions{{ aHasOKSystem }},
  317.         
  318.         // this returns false unless CPU is PCI Power Macintosh
  319.         checkAllAssertions{{ aPCIPowerMac }},
  320.         
  321.         // if PCI Power Macintosh CPU, add the Sample module package.
  322.         addCustomItems{{ pSample }},
  323.     }}
  324. };
  325.  
  326.  
  327. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  328. //
  329. // • Features (packages)
  330. //
  331. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  332.  
  333. resource 'inpk' (pSample) {
  334.     format0 {
  335.         showsOnCustom,            // show the package as a selectable item
  336.                                 // item when used as a subpackage
  337.                                 
  338.         removable,                // show under Custom Remove as a selectable
  339.                                 // item, when package is a subpackage
  340.                                 
  341.         forceRestart,            // require user reboot after installation
  342.         
  343.         0,                        // package comments resource ID
  344.         
  345.         0,                        // package size ( if 0, filled by ScriptCheck )
  346.         
  347.         "Basic Mac OS USB Components",        // Custom Install selection description
  348.         {    
  349.             'infa', faSampleDriver,            // file to install
  350.             'infa', faSampleShim,            // file to install
  351.         },
  352.     }
  353. };
  354.  
  355. resource 'inpk' (pSampleLiveUpdate) {
  356.     format0 {
  357.         showsOnCustom,            // show the package as a selectable item
  358.                                 // item when used as a subpackage
  359.                                 
  360.         removable,                // show under Custom Remove as a selectable
  361.                                 // item, when package is a subpackage
  362.                                 
  363.         dontForceRestart,            // require user reboot after installation
  364.         
  365.         0,                        // package comments resource ID
  366.         
  367.         0,                        // package size ( if 0, filled by ScriptCheck )
  368.         
  369.         "Basic Mac OS USB Components",        // Custom Install selection description
  370.         {    
  371.             'infa', faSampleDriver,            // file to install
  372.             'infa', faSampleShim,            // file to install
  373.             'inaa', aaAddShimToDisk,
  374.         },
  375.     }
  376. };
  377.  
  378. // • package comments
  379.  
  380. resource 'inpc' ( pSample ) {
  381.     format1 {
  382.         0,                        // sample date ( 08/08/94 seconds since 1904)
  383.         SampleHexVersion,            // sample version ( 8.0.1 GM)
  384.         
  385.         0,                        // Ignored, not shown in user interface
  386.         
  387.         0,                        // icon resource ID ( 'ICN#', 'icl4', 'icl8' )
  388.                                 // - ID must be greater than 1024
  389.                                 // - resource item is in included rsrc file
  390.                                 
  391.         pSample                    // 'TEXT' resource ID of item containing package description
  392.     }
  393. };
  394.  
  395. data 'TEXT' ( pSample )         { "This feature installs the Sample chip module and shim." };
  396.  
  397. resource 'inpc' ( pSampleLiveUpdate ) {
  398.     format1 {
  399.         0,                        // sample date ( 08/08/94 seconds since 1904)
  400.         SampleHexVersion,            // sample version ( 8.0.1 GM)
  401.         
  402.         0,                        // Ignored, not shown in user interface
  403.         
  404.         0,                        // icon resource ID ( 'ICN#', 'icl4', 'icl8' )
  405.                                 // - ID must be greater than 1024
  406.                                 // - resource item is in included rsrc file
  407.                                 
  408.         pSample                    // 'TEXT' resource ID of item containing package description
  409.     }
  410. };
  411.  
  412. data 'TEXT' ( pSampleLiveUpdate ) { "This feature installs the Sample Driver module and shim and activates the shim on the fly." };
  413.  
  414.  
  415. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  416. //
  417. // • File Copy Commands
  418. //
  419. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  420.  
  421. resource 'infa' (faSampleDriver) {
  422.     format1 {
  423.         deleteWhenRemoving,                //  Delete on deinstall
  424.         deleteWhenInstalling,            //  Remove preexisting
  425.         copy,                            //  Copy on Install
  426.         dontIgnoreLockedFile,            //  Respect file locking
  427.         dontSetFileLocked,                //  Leave installed file unlocked
  428.         useVersProcToCompare,            // Compare newness of file based on 'vers' resource
  429.         srcNeedNotExist,                //  Create a new file if necessary
  430.         
  431.         // this line must be set to "rsrcForkInDataFork" when working 
  432.         // file items compressed into InstaCompOne archives
  433.         rsrcForkInDataFork,                //  • Resource fork in Data fork
  434.         
  435.         leaveAloneIfNewer,                //  Do not update a newer file
  436.         updateExisting,                    //  Update an existing file
  437.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  438.         rsrcFork,                        //  Copy resource fork
  439.         dataFork,                        //  Copy data fork
  440.         
  441.         0,                    // TARGET - size ( filled in by ScriptCheck )
  442.         0x0,                // finder attribute flags ( filled in by ScriptCheck )
  443.         ftSampleDriver,        // TARGET - file spec ( 'intf' )
  444.         {    
  445.             fsSampleTome,            // SOURCE - file spec ( 'infs' )
  446.             0,                 // DATA fork - size ( filled in by ScriptCheck )
  447.             0                // RSRC fork - size ( filled in by ScriptCheck )
  448.         },    
  449.         
  450.         0x0,                // SOURCE - version number for comparisons
  451.                             // not used here
  452.                             
  453.         0,                    // 'invc' code resource - version comparison routine 
  454.                             //    ( none used here )
  455.         
  456.         242,                // 'inex' resource definition for atom extender
  457.                             // • #242 is for PPC InstaCompOne extender
  458.                             
  459.         "SampleDriver"        // file atom description
  460.     }
  461. };
  462.  
  463. resource 'infa' (faSampleShim) {
  464.     format1 {
  465.         deleteWhenRemoving,                //  Delete on deinstall
  466.         deleteWhenInstalling,            //  Remove preexisting
  467.         copy,                            //  Copy on Install
  468.         dontIgnoreLockedFile,            //  Respect file locking
  469.         dontSetFileLocked,                //  Leave installed file unlocked
  470.         useVersProcToCompare,            // Compare newness of file based on 'vers' resource
  471.         srcNeedNotExist,                //  Create a new file if necessary
  472.         
  473.         // this line must be set to "rsrcForkInDataFork" when working 
  474.         // file items compressed into InstaCompOne archives
  475.         rsrcForkInDataFork,                //  • Resource fork in Data fork
  476.         
  477.         leaveAloneIfNewer,                //  Do not update a newer file
  478.         updateExisting,                    //  Update an existing file
  479.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  480.         rsrcFork,                        //  Copy resource fork
  481.         dataFork,                        //  Copy data fork
  482.         
  483.         0,                    // TARGET - size ( filled in by ScriptCheck )
  484.         0x0,                // finder attribute flags ( filled in by ScriptCheck )
  485.         ftSampleShim,        // TARGET - file spec ( 'intf' )
  486.         {    
  487.             fsSampleTome,    // SOURCE - file spec ( 'infs' )
  488.             0,                 // DATA fork - size ( filled in by ScriptCheck )
  489.             0                // RSRC fork - size ( filled in by ScriptCheck )
  490.         },    
  491.         
  492.         0x0,                // SOURCE - version number for comparisons
  493.                             // not used here
  494.                             
  495.         0,                    // 'invc' code resource - version comparison routine 
  496.                             //    ( none used here )
  497.         
  498.         242,                // 'inex' resource definition for atom extender
  499.                             // • #241 is for PPCInstaCompOne extender
  500.                             
  501.         "SampleShim"    // file atom description
  502.     }
  503. };
  504.  
  505.  
  506. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  507. //
  508. // • Target File Descriptions
  509. //
  510. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  511.  
  512.  
  513. resource 'intf' (ftSampleDriver) {
  514.     format1 {
  515.         noSearchForFile,        // use default search path
  516.         TypeCrNeedNotMatch,        // target type and creator don't have to match
  517.         'ndrv',                    // TYPE given to new file
  518.         'usbd',                    // CREATOR given to new file
  519.         
  520.         0x0,                    // Target - finder flags
  521.                                 //    ( ScriptCheck fills in flags if set to 0 )
  522.         
  523.         0x1,                    // Target - creation date 
  524.         0x1,                    // Target - mod date 
  525.                                 //    ( ScriptCheck fills in dates if set to 1 )
  526.                                 
  527.         0,                        // 'insp' resource ID ( file search proc )
  528.         "special-extn:SampleDriver"    // path to target file
  529.     }
  530. };
  531.  
  532. resource 'intf' (ftSampleShim) {
  533.     format1 {
  534.         noSearchForFile,        // use default search path
  535.         TypeCrNeedNotMatch,        // target type and creator don't have to match
  536.         'ndrv',                    // TYPE given to new file
  537.         'usbs',                    // CREATOR given to new file
  538.         
  539.         0x0,                    // Target - finder flags
  540.                                 //    ( ScriptCheck fills in flags if set to 0 )
  541.         
  542.         0x1,                    // Target - creation date 
  543.         0x1,                    // Target - mod date 
  544.                                 //    ( ScriptCheck fills in dates if set to 1 )
  545.                                 
  546.         0,                        // 'insp' resource ID ( file search proc )
  547.         "special-extn:SampleShim"    // path to target file
  548.     }
  549. };
  550.  
  551.  
  552.  
  553. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  554. //
  555. // • Source File Descriptions
  556. //
  557. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  558.  
  559. // source file spec for Example File #1
  560. // • simple compression
  561. // source file spec for compressed "Example File" file 
  562. resource 'infs' (fsSampleTome) {
  563.     'idcp',                        // TYPE 
  564.     'kakc',                        // CREATOR 
  565.     0x0,                        // creation DATE for source file
  566.     noSearchForFile,            // IGNORED in Installer 4.0.x
  567.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  568.     "SampleDisk:SampleTome"    // PATH to source file        
  569. };
  570.  
  571. resource 'intf' (fsSystemFile)
  572. {
  573.     format1
  574.     {
  575.         noSearchForFile,
  576.         TypeCrNeedNotMatch,
  577.         'zsys',    'MACS',
  578.         0,
  579.         1,
  580.         1,
  581.         0,
  582.         "special-macs:System"                /* path name        */
  583.     };
  584. };
  585.  
  586. resource 'inaa' ( aaAddShimToDisk ) {
  587.     format2{
  588.         continueBusyCursors,
  589.         actAfter,                // when to run action atom
  590.         dontActOnRemove,        // run action atom on removal
  591.         actOnInstall,            // run action atom on install
  592.         'infn',                    // resource type of code resource
  593.         9000,                    // resource ID of code resource
  594.         0,                        // refcon ID
  595.         
  596.                 // NOTE: Enter zero for this value to use the installer's heap,
  597.         // or enter size in bytes to have this action atom use it's own heap.
  598.         // All earlier action atom formats use the installer's heap.
  599.         // IMPORTANT: enter zero for this field unless you have a specific
  600.         // reason for your action atom to use memory from it's own heap.
  601.         0,                        // requested memory in bytes
  602.  
  603.         "addShimFromDisk atom"    // description of atom
  604.     }
  605. };
  606.  
  607. resource 'inrf' (rlUSBVersFn14) {
  608.     format0 {
  609.         userFunctionType,        // code resource type
  610.         rlUSBVersFn14,            // code resource ID
  611.         0x01400000,                // refCon - USB 1.4 any release
  612.         
  613.         0,                        // use installer's heap, 
  614.                                 // instead of a seperate subheap
  615.         
  616.         "This Rule Function returns TRUE if USB v1.4 is active"
  617.         }
  618.     };
  619.  
  620.  
  621. resource 'STR ' (kShimSTRid) {"SampleShim"};
  622.